Vue.component('Add', {
	template: `
		<el-dialog title="添加" width="600px" class="icon-dialog" :visible.sync="show" @open="open" :before-close="closeForm" append-to-body>
			<el-form :size="size" ref="form" :model="form" :rules="rules" :label-width=" ismobile()?'90px':'16%'">
				<el-row >
					<el-col :span="24">
						<el-form-item label="联系人" prop="name">
							<el-input  v-model="form.name" autoComplete="off" clearable  placeholder="请输入联系人"></el-input>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row >
					<el-col :span="24">
						<el-form-item label="手机号码" prop="mobile">
							<el-input  v-model="form.mobile" autoComplete="off" clearable  placeholder="请输入手机号码"></el-input>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row >
					<el-col :span="24">
						<el-form-item label="标题" prop="title">
							<el-input  v-model="form.title" autoComplete="off" clearable  placeholder="请输入标题"></el-input>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row >
					<el-col :span="24">
						<el-form-item label="经营类型" prop="type">
							<el-input  v-model="form.type" autoComplete="off" clearable  placeholder="请输入经营类型"></el-input>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row >
					<el-col :span="24">
						<el-form-item label="物业类型" prop="property_type">
							<el-input  v-model="form.property_type" autoComplete="off" clearable  placeholder="请输入物业类型"></el-input>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row >
					<el-col :span="24">
						<el-form-item label="月租金/单位:(元)" prop="sell">
							<el-input  v-model="form.sell" autoComplete="off" clearable  placeholder="请输入月租金/单位:(元)"></el-input>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row >
					<el-col :span="24">
						<el-form-item label="转让费/单位(万元)" prop="cede">
							<el-input  v-model="form.cede" autoComplete="off" clearable  placeholder="请输入转让费/单位(万元)"></el-input>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row >
					<el-col :span="24">
						<el-form-item label="面积/单位(m2)" prop="area">
							<el-input  v-model="form.area" autoComplete="off" clearable  placeholder="请输入面积/单位(m2)"></el-input>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row >
					<el-col :span="24">
						<el-form-item label="剩余租期" prop="lease_term">
							<el-input  v-model="form.lease_term" autoComplete="off" clearable  placeholder="请输入剩余租期"></el-input>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row >
					<el-col :span="24">
						<el-form-item label="区域" prop="regoin">
							<el-input  v-model="form.regoin" autoComplete="off" clearable  placeholder="请输入区域"></el-input>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row >
					<el-col :span="24">
						<el-form-item label="联系地址" prop="contact_address">
							<el-input  v-model="form.contact_address" autoComplete="off" clearable  placeholder="请输入联系地址"></el-input>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row >
					<el-col :span="24">
						<el-form-item label="押付" prop="deposit">
							<el-input  v-model="form.deposit" autoComplete="off" clearable  placeholder="请输入押付"></el-input>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row >
					<el-col :span="24">
						<el-form-item label="商铺性质/(新房)(旧房)" prop="shop">
							<el-input  v-model="form.shop" autoComplete="off" clearable  placeholder="请输入商铺性质/(新房)(旧房)"></el-input>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row >
					<el-col :span="24">
						<el-form-item label="商铺类型" prop="storetype">
							<el-input  v-model="form.storetype" autoComplete="off" clearable  placeholder="请输入商铺类型"></el-input>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row >
					<el-col :span="24">
						<el-form-item label="经营状态" prop="business_status">
							<el-input  v-model="form.business_status" autoComplete="off" clearable  placeholder="请输入经营状态"></el-input>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row >
					<el-col :span="24">
						<el-form-item label="房屋规格" prop="specs">
							<el-input  v-model="form.specs" autoComplete="off" clearable  placeholder="请输入房屋规格"></el-input>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row >
					<el-col :span="24">
						<el-form-item label="店铺描述" prop="info">
							<el-input  type="textarea" autoComplete="off" v-model="form.info"  :autosize="{ minRows: 2, maxRows: 4}" clearable placeholder="请输入店铺描述"/>
						</el-form-item>
					</el-col>
				</el-row>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button :size="size" :loading="loading" type="primary" @click="submit" >
					<span v-if="!loading">确 定</span>
					<span v-else>提 交 中...</span>
				</el-button>
				<el-button :size="size" @click="closeForm">取 消</el-button>
			</div>
		</el-dialog>
	`
	,
	components:{
	},
	props: {
		show: {
			type: Boolean,
			default: false
		},
		size: {
			type: String,
			default: 'small'
		},
	},
	data(){
		return {
			form: {
				name:'',
				mobile:'',
				title:'',
				type:'',
				property_type:'',
				sell:'',
				cede:'',
				area:'',
				lease_term:'',
				regoin:'',
				contact_address:'',
				deposit:'',
				shop:'',
				storetype:'',
				business_status:'',
				specs:'',
				info:'',
			},
			loading:false,
			rules: {
				name:[
					{required: true, message: '联系人不能为空', trigger: 'blur'},
				],
				mobile:[
					{required: true, message: '手机号码不能为空', trigger: 'blur'},
				],
				title:[
					{required: true, message: '标题不能为空', trigger: 'blur'},
				],
			}
		}
	},
	methods: {
		open(){
		},
		submit(){
			this.$refs['form'].validate(valid => {
				if(valid) {
					this.loading = true
					axios.post(base_url + '/InfoSubmit/add',this.form).then(res => {
						if(res.data.status == 200){
							this.$message({message: res.data.msg, type: 'success'})
							this.$emit('refesh_list')
							this.closeForm()
						}else{
							this.loading = false
							this.$message.error(res.data.msg)
						}
					}).catch(()=>{
						this.loading = false
					})
				}
			})
		},
		closeForm(){
			this.$emit('update:show', false)
			this.loading = false
			if (this.$refs['form']!==undefined) {
				this.$refs['form'].resetFields()
			}
		},
	}
})
